<?php


/**
 * Base class that represents a query for the 'poul' table.
 *
 * 
 *
 * @method     PoulQuery orderByPoulid($order = Criteria::ASC) Order by the poulID column
 * @method     PoulQuery orderByPoulleider($order = Criteria::ASC) Order by the poulleider column
 * @method     PoulQuery orderByNaam($order = Criteria::ASC) Order by the naam column
 * @method     PoulQuery orderByKosten($order = Criteria::ASC) Order by the kosten column
 * @method     PoulQuery orderByPubliek($order = Criteria::ASC) Order by the publiek column
 *
 * @method     PoulQuery groupByPoulid() Group by the poulID column
 * @method     PoulQuery groupByPoulleider() Group by the poulleider column
 * @method     PoulQuery groupByNaam() Group by the naam column
 * @method     PoulQuery groupByKosten() Group by the kosten column
 * @method     PoulQuery groupByPubliek() Group by the publiek column
 *
 * @method     PoulQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     PoulQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     PoulQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     PoulQuery leftJoinGebruiker($relationAlias = null) Adds a LEFT JOIN clause to the query using the Gebruiker relation
 * @method     PoulQuery rightJoinGebruiker($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Gebruiker relation
 * @method     PoulQuery innerJoinGebruiker($relationAlias = null) Adds a INNER JOIN clause to the query using the Gebruiker relation
 *
 * @method     PoulQuery leftJoinKoppelGebruikerPoul($relationAlias = null) Adds a LEFT JOIN clause to the query using the KoppelGebruikerPoul relation
 * @method     PoulQuery rightJoinKoppelGebruikerPoul($relationAlias = null) Adds a RIGHT JOIN clause to the query using the KoppelGebruikerPoul relation
 * @method     PoulQuery innerJoinKoppelGebruikerPoul($relationAlias = null) Adds a INNER JOIN clause to the query using the KoppelGebruikerPoul relation
 *
 * @method     PoulQuery leftJoinPunten($relationAlias = null) Adds a LEFT JOIN clause to the query using the Punten relation
 * @method     PoulQuery rightJoinPunten($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Punten relation
 * @method     PoulQuery innerJoinPunten($relationAlias = null) Adds a INNER JOIN clause to the query using the Punten relation
 *
 * @method     PoulQuery leftJoinVoorspelling($relationAlias = null) Adds a LEFT JOIN clause to the query using the Voorspelling relation
 * @method     PoulQuery rightJoinVoorspelling($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Voorspelling relation
 * @method     PoulQuery innerJoinVoorspelling($relationAlias = null) Adds a INNER JOIN clause to the query using the Voorspelling relation
 *
 * @method     Poul findOne(PropelPDO $con = null) Return the first Poul matching the query
 * @method     Poul findOneOrCreate(PropelPDO $con = null) Return the first Poul matching the query, or a new Poul object populated from the query conditions when no match is found
 *
 * @method     Poul findOneByPoulid(int $poulID) Return the first Poul filtered by the poulID column
 * @method     Poul findOneByPoulleider(int $poulleider) Return the first Poul filtered by the poulleider column
 * @method     Poul findOneByNaam(string $naam) Return the first Poul filtered by the naam column
 * @method     Poul findOneByKosten(double $kosten) Return the first Poul filtered by the kosten column
 * @method     Poul findOneByPubliek(int $publiek) Return the first Poul filtered by the publiek column
 *
 * @method     array findByPoulid(int $poulID) Return Poul objects filtered by the poulID column
 * @method     array findByPoulleider(int $poulleider) Return Poul objects filtered by the poulleider column
 * @method     array findByNaam(string $naam) Return Poul objects filtered by the naam column
 * @method     array findByKosten(double $kosten) Return Poul objects filtered by the kosten column
 * @method     array findByPubliek(int $publiek) Return Poul objects filtered by the publiek column
 *
 * @package    propel.generator.database.om
 */
abstract class BasePoulQuery extends ModelCriteria
{

	/**
	 * Initializes internal state of BasePoulQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'database', $modelName = 'Poul', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new PoulQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    PoulQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof PoulQuery) {
			return $criteria;
		}
		$query = new PoulQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key
	 * Use instance pooling to avoid a database query if the object exists
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Poul|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ((null !== ($obj = PoulPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
			// the object is alredy in the instance pool
			return $obj;
		} else {
			// the object has not been requested yet, or the formatter is not an object formatter
			$criteria = $this->isKeepQuery() ? clone $this : $this;
			$stmt = $criteria
				->filterByPrimaryKey($key)
				->getSelectStatement($con);
			return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
		}
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{	
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		return $this
			->filterByPrimaryKeys($keys)
			->find($con);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(PoulPeer::POULID, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(PoulPeer::POULID, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the poulID column
	 * 
	 * @param     int|array $poulid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPoulid($poulid = null, $comparison = null)
	{
		if (is_array($poulid) && null === $comparison) {
			$comparison = Criteria::IN;
		}
		return $this->addUsingAlias(PoulPeer::POULID, $poulid, $comparison);
	}

	/**
	 * Filter the query on the poulleider column
	 * 
	 * @param     int|array $poulleider The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPoulleider($poulleider = null, $comparison = null)
	{
		if (is_array($poulleider)) {
			$useMinMax = false;
			if (isset($poulleider['min'])) {
				$this->addUsingAlias(PoulPeer::POULLEIDER, $poulleider['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($poulleider['max'])) {
				$this->addUsingAlias(PoulPeer::POULLEIDER, $poulleider['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PoulPeer::POULLEIDER, $poulleider, $comparison);
	}

	/**
	 * Filter the query on the naam column
	 * 
	 * @param     string $naam The value to use as filter.
	 *            Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByNaam($naam = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($naam)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $naam)) {
				$naam = str_replace('*', '%', $naam);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(PoulPeer::NAAM, $naam, $comparison);
	}

	/**
	 * Filter the query on the kosten column
	 * 
	 * @param     double|array $kosten The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByKosten($kosten = null, $comparison = null)
	{
		if (is_array($kosten)) {
			$useMinMax = false;
			if (isset($kosten['min'])) {
				$this->addUsingAlias(PoulPeer::KOSTEN, $kosten['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($kosten['max'])) {
				$this->addUsingAlias(PoulPeer::KOSTEN, $kosten['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PoulPeer::KOSTEN, $kosten, $comparison);
	}

	/**
	 * Filter the query on the publiek column
	 * 
	 * @param     int|array $publiek The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPubliek($publiek = null, $comparison = null)
	{
		if (is_array($publiek)) {
			$useMinMax = false;
			if (isset($publiek['min'])) {
				$this->addUsingAlias(PoulPeer::PUBLIEK, $publiek['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($publiek['max'])) {
				$this->addUsingAlias(PoulPeer::PUBLIEK, $publiek['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(PoulPeer::PUBLIEK, $publiek, $comparison);
	}

	/**
	 * Filter the query by a related Gebruiker object
	 *
	 * @param     Gebruiker $gebruiker  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByGebruiker($gebruiker, $comparison = null)
	{
		return $this
			->addUsingAlias(PoulPeer::POULLEIDER, $gebruiker->getGebruikerid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the Gebruiker relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function joinGebruiker($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Gebruiker');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Gebruiker');
		}
		
		return $this;
	}

	/**
	 * Use the Gebruiker relation Gebruiker object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    GebruikerQuery A secondary query class using the current class as primary query
	 */
	public function useGebruikerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinGebruiker($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Gebruiker', 'GebruikerQuery');
	}

	/**
	 * Filter the query by a related KoppelGebruikerPoul object
	 *
	 * @param     KoppelGebruikerPoul $koppelGebruikerPoul  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByKoppelGebruikerPoul($koppelGebruikerPoul, $comparison = null)
	{
		return $this
			->addUsingAlias(PoulPeer::POULID, $koppelGebruikerPoul->getPoulid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the KoppelGebruikerPoul relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function joinKoppelGebruikerPoul($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('KoppelGebruikerPoul');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'KoppelGebruikerPoul');
		}
		
		return $this;
	}

	/**
	 * Use the KoppelGebruikerPoul relation KoppelGebruikerPoul object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    KoppelGebruikerPoulQuery A secondary query class using the current class as primary query
	 */
	public function useKoppelGebruikerPoulQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinKoppelGebruikerPoul($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'KoppelGebruikerPoul', 'KoppelGebruikerPoulQuery');
	}

	/**
	 * Filter the query by a related Punten object
	 *
	 * @param     Punten $punten  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByPunten($punten, $comparison = null)
	{
		return $this
			->addUsingAlias(PoulPeer::POULID, $punten->getPoulid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the Punten relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function joinPunten($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Punten');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Punten');
		}
		
		return $this;
	}

	/**
	 * Use the Punten relation Punten object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PuntenQuery A secondary query class using the current class as primary query
	 */
	public function usePuntenQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinPunten($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Punten', 'PuntenQuery');
	}

	/**
	 * Filter the query by a related Voorspelling object
	 *
	 * @param     Voorspelling $voorspelling  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function filterByVoorspelling($voorspelling, $comparison = null)
	{
		return $this
			->addUsingAlias(PoulPeer::POULID, $voorspelling->getPoulid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the Voorspelling relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function joinVoorspelling($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('Voorspelling');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'Voorspelling');
		}
		
		return $this;
	}

	/**
	 * Use the Voorspelling relation Voorspelling object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    VoorspellingQuery A secondary query class using the current class as primary query
	 */
	public function useVoorspellingQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinVoorspelling($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'Voorspelling', 'VoorspellingQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Poul $poul Object to remove from the list of results
	 *
	 * @return    PoulQuery The current query, for fluid interface
	 */
	public function prune($poul = null)
	{
		if ($poul) {
			$this->addUsingAlias(PoulPeer::POULID, $poul->getPoulid(), Criteria::NOT_EQUAL);
	  }
	  
		return $this;
	}

} // BasePoulQuery
